package com.example.administrator.foodrowfresh;

import android.app.Application;

import org.xutils.DbManager;
import org.xutils.x;

/**
 * Created by lqr on 2016/4/30.
 */
public class MyApplication extends Application {
    private DbManager.DaoConfig mDaoConfig;
    @Override
    public void onCreate() {
        super.onCreate();
        x.Ext.init(this);
    }
    @Override
    public void onTerminate() {
        super.onTerminate();
    }

    public static DbManager.DaoConfig getDaoConfig(MyApplication mApplication){
        if(mApplication.mDaoConfig==null){
            mApplication.mDaoConfig=new DbManager.DaoConfig()
                    // 设置是否可以使用事务
                    .setAllowTransaction(true)
                            // 设置数据库的名字
                    .setDbName("cat_food.db")
                            // 设置数据库的版本号
                    .setDbVersion(1)
                            // 设置数据库跟新的回调监听
                    .setDbUpgradeListener(new DbManager.DbUpgradeListener() {
                        @Override
                        public void onUpgrade(DbManager db, int oldVersion, int newVersion) {

                        }
                    });
        }
        return mApplication.mDaoConfig;
    }

}
